home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / rl / build-bin / createupdates < prev    next >
Encoding:
Text File  |  2001-05-29  |  2.8 KB  |  146 lines

  1. #!/bin/sh
  2. # createupdates - create the necessary file to support the rlupdate
  3. # program
  4. # copyright (c) 2001 Joseph Cheek, Redmond Linux Corp.  Released under
  5. # GPL.
  6.  
  7. FTPBASEDIR=/home/ftp
  8. RLBASEDIR=$FTPBASEDIR/pub/linux/redmondlinux
  9. UPDATEBASEDIR=$RLBASEDIR/updates/amethyst-personal
  10. RPMSBASEDIR=$UPDATEBASEDIR/RPMS
  11.  
  12.  
  13. _getrpmlist() {
  14. #return a list of all RPM files in dir $1
  15.  
  16.   ls "$1/"*.rpm | cat
  17.  
  18. }
  19.  
  20.  
  21. _createupdates_xml() {
  22.  
  23.  
  24. __createupdates_header() {
  25.  
  26. cat << EOF
  27. <?xml version="1.0" encoding="UTF-8"?>
  28. <!DOCTYPE updatelist SYSTEM "updates.dtd">
  29. <updatelist>
  30. EOF
  31.  
  32. }
  33.  
  34.  
  35. __createupdates_body() {
  36. # create the body for package $1 according to the following pattern:
  37.  
  38. # <update category="security">
  39. #   <name>XFree86</name>
  40. #   <date>2000/05/26</date>
  41. #   <url>ftp://ftp.calderasystems.com/pub/security/CSSA-2000-012.0.txt</url>
  42. #   <synopsis>
  43. #     A bug was discovered in the X server's authentication code that
  44. #     allows a remote user to completely hang the victim's X server
  45. #   </synopsis>
  46. #   <package demand="required" action="install">
  47. #     <query>XFree86</query>
  48. #     <name>XFree86</name>
  49. #     <version>3.3.6-4</version>
  50. #     <arch>i386</arch>
  51. #     <size>824777</size>
  52. #   </package> 
  53. # </update>
  54.  
  55. _UP_CATEGORY="new build"
  56. _UP_NAME=`rpmextr --tag=name $1`
  57. _UP_DATE=`date +%Y/%m/%d`
  58. _UP_URL="http://www.redmondlinux.org/"
  59. _UP_SYNOPSIS="Updated for build $LATEST_BUILD"
  60. _PKG_DEMAND="required"
  61. _PKG_ACTION="install"
  62. _PKG_QUERY=`rpmextr --tag=name $1`
  63. _PKG_NAME=`rpmextr --tag=summary $1 | sed s/\&/and/g`
  64. _PKG_VERSION=`rpmextr --tag=version $1`-`rpmextr --tag=release $1`
  65. _PKG_ARCH=`echo $1 | tr . \\\\n | tail -n 2 | head -n 1`
  66. _PKG_SIZE=`ls -l $1 | tr -s \  | cut -d \  -f 5`
  67.  
  68. #  echo \# $1
  69.  
  70.   cat << EOF
  71.  
  72.  
  73. <update category="$_UP_CATEGORY">
  74.   <name>$_UP_NAME</name>
  75.   <date>$_UP_DATE</date>
  76.   <url>$_UP_URL</url>
  77.   <synopsis>
  78.     $_UP_SYNOPSIS
  79.   </synopsis>
  80.   <package demand="$_PKG_DEMAND" action="$_PKG_ACTION">
  81.     <query>$_PKG_QUERY</query>
  82.     <name>$_PKG_NAME</name>
  83.     <version>$_PKG_VERSION</version>
  84.     <arch>$_PKG_ARCH</arch>
  85.     <size>$_PKG_SIZE</size>
  86.   </package>
  87. </update>
  88. EOF
  89.  
  90. }
  91.  
  92.  
  93. __createupdates_footer() {
  94.  
  95. cat << EOF
  96. </updatelist>
  97. EOF
  98.  
  99. }
  100.  
  101.   local filename FILES;
  102.  
  103.   __createupdates_header > $UPDATEBASEDIR/updates.xml
  104.  
  105.   FILES=`_getrpmlist $RPMSBASEDIR` || return 1
  106.  
  107.   for filename in $FILES; do
  108.     __createupdates_body $filename >> $UPDATEBASEDIR/updates.xml
  109.   done
  110.  
  111.   __createupdates_footer >> $UPDATEBASEDIR/updates.xml
  112.  
  113. }
  114.  
  115.  
  116. _signupdates_xml() {
  117.  
  118.   gpg --yes -sb $UPDATEBASEDIR/updates.xml || return 1
  119.  
  120. }
  121.  
  122.  
  123. _getlatestbuild() {
  124.  
  125.   echo -n What is the latest build \#\?\ 
  126.   read LATEST_BUILD
  127.  
  128. }
  129.  
  130.  
  131. _exit_error() {
  132.  
  133.   echo $* >&2
  134.   exit 1
  135.  
  136. }
  137.  
  138.  
  139. # main()
  140.  
  141.   _getlatestbuild || _exit_error "could not get latest build #"
  142.   _createupdates_xml || _exit_error "could not create updates.xml file"
  143.   _signupdates_xml || _exit_error "could not sign updates.xml file"
  144.  
  145. exit 0
  146.